﻿using M.ShopMachine.Repository.Interface;
using M.ShopMachine.Write.WebApi.Application.Command.DeviceCommand;
using MediatR;

namespace M.ShopMachine.Write.WebApi.Application.Handler.DeviceHandler
{
    public class UpdShopDeviceHandler : IRequestHandler<UpdShopDeviceCommand, int>
    {
        private readonly IDeviceRepository deviceRepository;

        public UpdShopDeviceHandler(IDeviceRepository deviceRepository)
        {
            this.deviceRepository = deviceRepository;
        }

        public async Task<int> Handle(UpdShopDeviceCommand request, CancellationToken cancellationToken)
        {
            return await deviceRepository.UpdShopDeviceAsync(request.WorkshopId,request.DeviceIds);
        }
    }
}
